package com.test.demos.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.test.demos.pojo.entity.UserInstitutionRelation;
import com.test.demos.service.UserInstitutionRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.test.demos.utils.Result;

/**
 * 体检机构的员工
 *
 * @author twt
 * @since 2025-04-14 16:27:02
 */
@CrossOrigin
@RestController
@RequestMapping("userInstitutionRelation")
public class UserInstitutionRelationController {

    /**
     * 服务对象
     */
    @Autowired
    private UserInstitutionRelationService userInstitutionRelationService;

    /**
     * 通过ID查询单条数据
     *
     * @param relationId 主键
     * @return 实例对象
     */
    @GetMapping("{id}")
    public Result<UserInstitutionRelation> queryById(@PathVariable("id") Integer relationId) {
        return Result.ok(userInstitutionRelationService.queryById(relationId));
    }



    /**
     * 新增数据
     *
     * @param userInstitutionRelation 实例对象
     * @return 实例对象
     */
    @PostMapping
    public Result<UserInstitutionRelation> add(@RequestBody UserInstitutionRelation userInstitutionRelation) {
        userInstitutionRelationService.add(userInstitutionRelation);
        return Result.ok(userInstitutionRelation);
    }

    /**
     * 更新数据
     *
     * @param userInstitutionRelation 实例对象
     */
    @PutMapping
    public Result update(@RequestBody UserInstitutionRelation userInstitutionRelation) {
        userInstitutionRelationService.update(userInstitutionRelation);
        return Result.ok();
    }

    /**
     * 通过主键删除数据
     *
     * @param relationId 主键
     * @return 是否成功
     */
    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable("id") Integer relationId) {
        userInstitutionRelationService.deleteById(relationId);
        return Result.ok();
    }
}
